package edu.whut.mall.portal.dto;

import org.apache.commons.lang3.builder.ToStringBuilder;

/**
 * @program: d9lab-mall
 * @description: 团购发起或者参与资格dto
 * @author: Wayne
 * @create: 2020-05-18 13:58
 **/

public class GroupBuyQualificationResult {

    private boolean qualified;

    private int buyCount;

    private Long groupBuyRuleId;

    private Integer ruleLimitNumber;

    private String failMessage;

   private GroupBuyQualificationResult(boolean qualified, int buyCount, String failMessage) {
        this.qualified = qualified;
        this.buyCount = buyCount;
        this.failMessage = failMessage;
    }

    public GroupBuyQualificationResult(boolean qualified, int buyCount, Long groupBuyRuleId, String failMessage, Integer ruleLimitNumber) {
        this.qualified = qualified;
        this.buyCount = buyCount;
        this.groupBuyRuleId = groupBuyRuleId;
        this.failMessage = failMessage;
        this.ruleLimitNumber = ruleLimitNumber;
    }

    public boolean isQualified() {
        return qualified;
    }

    public int getBuyCount() {
        return buyCount;
    }

    public String getFailMessage() {
        return failMessage;
    }

    public Long getGroupBuyRuleId() {
        return groupBuyRuleId;
    }

    public void setQualified(boolean qualified) {
        this.qualified = qualified;
    }

    public void setBuyCount(int buyCount) {
        this.buyCount = buyCount;
    }

    public void setGroupBuyRuleId(Long groupBuyRuleId) {
        this.groupBuyRuleId = groupBuyRuleId;
    }

    public void setFailMessage(String failMessage) {
        this.failMessage = failMessage;
    }

    public Integer getRuleLimitNumber() {
        return ruleLimitNumber;
    }

    public void setRuleLimitNumber(Integer ruleLimitNumber) {
        this.ruleLimitNumber = ruleLimitNumber;
    }

    public static GroupBuyQualificationResult successWithCount(int count){
        return new GroupBuyQualificationResult(true, count,null);
    }
    public static GroupBuyQualificationResult successWithRuleId(Long ruleId, Integer ruleLimitNumber){
        return new GroupBuyQualificationResult(true, 0, ruleId, null, ruleLimitNumber);
    }

    public static GroupBuyQualificationResult fail(String failMessage){
       return new GroupBuyQualificationResult(false, 0, failMessage);
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("qualified", qualified)
                .append("buyCount", buyCount)
                .append("groupBuyRuleId", groupBuyRuleId)
                .append("ruleLimitNumber", ruleLimitNumber)
                .append("failMessage", failMessage)
                .toString();
    }
}
